from time import*
file1 = open('m1_sorted.txt').readlines()
mas1 = list()
for d in range(len(file1)):
    mas1.append(int(file1[d]))
N1=len(mas1)
start1=time()
for i in range(N1-1):
    k1=0
    for j in range (N1-i-1):
        if mas1[j] > mas1[j+1]:
            mas1[j], mas1[j+1] = mas1[j+1], mas1[j]
            k1+=1
    if k1==0:
        break
end1=time()
tt1 = end1-start1
print('m1_sorted.txt', int(round(tt1*1000)), 'milliseconds', mas1)
#------------------------------------------
file2 = open('m2_reverse.txt').readlines()
mas2 = list()
for d in range(len(file2)):
    mas2.append(int(file2[d]))
N2=len(mas2)
start2=time()
for i in range(N2-1):
    k2=0
    for j in range (N2-i-1):
        if mas2[j] > mas2[j+1]:
            mas2[j], mas2[j+1] = mas2[j+1], mas2[j]
            k2+=1
    if k2==0:
        break
end2=time()
tt2 = end2-start2
print('m2_reverse.txt', int(round(tt2*1000)), 'milliseconds', mas2)
#------------------------------------
file3 = open('m3_shuffle.txt').readlines()
mas3 = list()
for x in range(len(file3)):
    mas3.append(int(file3[x]))
N3=len(mas3)
start3=time()
for v in range(N3-1):
    k3=0
    for n in range (N3-v-1):
        if mas3[n] > mas3[n+1]:
            mas3[n], mas3[n+1] = mas3[n+1], mas3[n]
            k3+=1
    if k3==0:
        break
end3=time()
tt3 = end3-start3
print('m3_shuffle.txt', int(round(tt3*1000)), 'milliseconds', mas3)
